package org.spring.aicloud.utils;

import org.spring.aicloud.entity.SecurityUserDetails;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * @author yexiebao
 * @date 2025/5/18
 */
public class SecurityUtil {
    /**
     * 获取当前登录用户
     * @return
     */
    public static SecurityUserDetails getCurrentUser(){
        SecurityUserDetails userDetails = null;
        try {
            userDetails = (SecurityUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        }catch (Exception e){
        }
        return userDetails;
    }
}